import { NodeCanvasRenderingContext2D } from 'canvas';
import { Actor } from './Actor';

export class Scene {
	constructor(actors?: Actor[]) {
		if (actors) {
			this.actors = this.actors.concat(actors);
		}
	}

	public addActor(actor: Actor): Scene {
		this.actors.push(actor);
		return this;
	}

	public render(ctx: NodeCanvasRenderingContext2D, frame: number, time: number) {
		this.actors.forEach(actor => actor.render(ctx, frame, time));
	}

	private actors: Actor[] = [];
}
